<?php session_start(); ?>
<?php ob_start(); ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false); 
header("Cache-Control: private");
header("Pragma: no-cache"); // HTTP/1.0 
?>
<?php include ("../ewconfig.php") ?>
<?php include ("../db.php") ?>
<?php include ("../advsecu.php") ?>
<?php include ("../phpmkrfn.php") ?>
<?php include ("../ewupload.php") ?>
<?php
if (!IsLoggedIn()) {
	ob_end_clean();
	header("Location: login.php");
	exit();
}
?>
<?php //include ("../phpmkrfn.php") ?>
<?php require_once('../Connections/MYCONN.php'); ?>
<?php

global $parentid;
global $CheckAmt;
global $CashAmt;
global $CreditAmt;
global $DepositAmt;
global $LunchAmt;
global $MetroAmt;
global $OverringAmt;
global $PayoutAmt;
global $IPPSaleAmt;
global $XReadingAmt;

if($parentid == ""){
$parentid=0;
}

function IsNull($theValue)
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
  $theValue = ($theValue != "") ? $theValue : "";
  return trim($theValue);
}


function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "0";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
  $insertSQL = sprintf("INSERT INTO tb_checks (BankName, Amount, ParentID) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['textfield'], "text"),
                       GetSQLValueString($_POST['textfield2'], "double"),
                       GetSQLValueString($_POST['textfield3'], "int"));

  mysql_select_db($database_MYCONN, $MYCONN);
  $Result1 = mysql_query($insertSQL, $MYCONN) or die(mysql_error());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form3")) {
  $insertSQL = sprintf("INSERT INTO tb_creditcard (ParentID, CardType, Amount) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['textfield5'], "int"),
                       GetSQLValueString($_POST['textfield4'], "text"),
                       GetSQLValueString($_POST['textfield6'], "double"));

  mysql_select_db($database_MYCONN, $MYCONN);
  $Result1 = mysql_query($insertSQL, $MYCONN) or die(mysql_error());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form4")) {
  $insertSQL = sprintf("INSERT INTO tb_metrocard (ParentID, Description, Amount) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['MetroParentID'], "int"),
                       GetSQLValueString($_POST['MetroDesc'], "text"),
                       GetSQLValueString($_POST['MetroAmt'], "double"));

  mysql_select_db($database_MYCONN, $MYCONN);
  $Result1 = mysql_query($insertSQL, $MYCONN) or die(mysql_error());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmDeposit")) {
  $insertSQL = sprintf("INSERT INTO tb_deposits (ParentID, Description, Amount) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['DepositParentID'], "int"),
                       GetSQLValueString($_POST['DepositDesc'], "text"),
                       GetSQLValueString($_POST['DepositAmount'], "double"));

  mysql_select_db($database_MYCONN, $MYCONN);
  $Result1 = mysql_query($insertSQL, $MYCONN) or die(mysql_error());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmLunch")) {
  $insertSQL = sprintf("INSERT INTO tb_lunchamt (ParentID, Description, Amount) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['LunchParentID'], "int"),
                       GetSQLValueString($_POST['LunchDesc'], "text"),
                       GetSQLValueString($_POST['Lunchamt'], "double"));

  mysql_select_db($database_MYCONN, $MYCONN);
  $Result1 = mysql_query($insertSQL, $MYCONN) or die(mysql_error());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmOverring")) {
  $insertSQL = sprintf("INSERT INTO tb_overrings (ParentID, Description, Amount) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['OverringParentID'], "int"),
                       GetSQLValueString($_POST['OverringDesc'], "text"),
                       GetSQLValueString($_POST['OverringAmt'], "double"));

  mysql_select_db($database_MYCONN, $MYCONN);
  $Result1 = mysql_query($insertSQL, $MYCONN) or die(mysql_error());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmCash")) {
  $insertSQL = sprintf("INSERT INTO tb_cash (ParentID, Cash_Hundred, Cash_Fifty, Cash_twenty, Cash_Ten, Cash_five, Cash_single, Roll_Quarter, Coin_Quarter, Roll_Dime, Coin_Dime, Roll_Nickle, Coin_Nickle, Roll_Penny, Coin_Penny, Coin_Dollar, Coin_Halfdollar) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString(($_POST['CashParentID']=="")?0:$_POST['CashParentID'], "int"),
                       GetSQLValueString(($_POST['Cash_HundredAmt']=="")?0:$_POST['Cash_HundredAmt'], "int"),
                       GetSQLValueString(($_POST['Cash_Fifty']=="")?0:$_POST['Cash_Fifty'], "int"),
                       GetSQLValueString(($_POST['Cash_twenty']=="")?0:$_POST['Cash_twenty'], "int"),
                       GetSQLValueString(($_POST['Cash_Ten']=="")?0:$_POST['Cash_Ten'], "int"),
                       GetSQLValueString(($_POST['Cash_five']=="")?0:$_POST['Cash_five'], "int"),
                       GetSQLValueString(($_POST['Cash_single']=="")?0:$_POST['Cash_single'], "int"),
                       GetSQLValueString(($_POST['Roll_Quarter']=="")?0:$_POST['Roll_Quarter'], "int"),
                       GetSQLValueString(($_POST['Coin_Quarter']=="")?0:$_POST['Coin_Quarter'], "int"),					   
                       GetSQLValueString(($_POST['Roll_Dime']=="")?0:$_POST['Roll_Dime'], "int"),
                       GetSQLValueString(($_POST['Coin_Dime']=="")?0:$_POST['Coin_Dime'], "int"),					   
                       GetSQLValueString(($_POST['Roll_Nickle']=="")?0:$_POST['Roll_Nickle'], "int"),
                       GetSQLValueString(($_POST['Coin_Nickle']=="")?0:$_POST['Coin_Nickle'], "int"),					   
                       GetSQLValueString(($_POST['Roll_Penny']=="")?0:$_POST['Roll_Penny'], "int"),
                       GetSQLValueString(($_POST['Coin_Penny']=="")?0:$_POST['Coin_Penny'], "int"),					   
                       GetSQLValueString(($_POST['Coin_Dollar']=="")?0:$_POST['Coin_Dollar'], "int"),
                       GetSQLValueString(($_POST['Coin_Halfdollar']=="")?0:$_POST['Coin_Halfdollar'], "int"));

//echo $insertSQL;
  mysql_select_db($database_MYCONN, $MYCONN);
  $Result1 = mysql_query($insertSQL, $MYCONN) or die(mysql_error());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmPayout")) {
  $insertSQL = sprintf("INSERT INTO tb_payouts (ParentID, Description, Amount) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['PayoutParentID'], "int"),
                       GetSQLValueString($_POST['PayoutDesc'], "text"),
                       GetSQLValueString($_POST['PayoutAmt'], "double"));

  mysql_select_db($database_MYCONN, $MYCONN);
  $Result1 = mysql_query($insertSQL, $MYCONN) or die(mysql_error());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

 
 
/* $strSQL = "select count(*) as cnt from tb_cashlog where UserID = ".GetSQLValueString($_POST['frmUserID'], "int")." and ".
" logdate = '".GetSQLValueString($_POST['frmlogdate'], "date")."' and RegisterID = ".GetSQLValueString($_POST['frmreigisterID'], "int"));

$Rs = mysql_query($strSQL, $MYCONN) or die(mysql_error());
$row_rs = mysql_fetch_assoc($Rs);
$totalRows_Rs = mysql_num_rows($Rs);

if($totalRows_Rs > 0){


} */


  $insertSQL = sprintf("INSERT INTO tb_cashlog (UserID, LogDate, LocationID, TotalIPPSales, XReading, RegisterID) VALUES (%s, %s, %s,%s,%s, %s)",
						GetSQLValueString($_POST['frmUserID'], "int"),
						GetSQLValueString($_POST['frmlogdate'], "date"),
						GetSQLValueString($_POST['frmLocationID'], "int"),
						GetSQLValueString($_POST['frmippsales'], "double"),
						GetSQLValueString($_POST['frmxreading'], "double"),
						GetSQLValueString($_POST['frmreigisterID'], "int"));

 
 mysql_select_db($database_MYCONN, $MYCONN);
  $Result1 = mysql_query($insertSQL, $MYCONN) or die(mysql_error());

  $insertGoTo = "aaa3.php?ID=".mysql_insert_id();


header(sprintf("Location: %s", $insertGoTo));
}
 
mysql_select_db($database_MYCONN, $MYCONN);
if( isset($_GET["ID"]) && $_GET["ID"] != ""  )
{
$query_RecCashLog = "SELECT * FROM tb_cashlog WHERE ID = ".$_GET["ID"];
$parentid = $_GET["ID"];
}else 
{
$query_RecCashLog = "SELECT * FROM tb_cashlog WHERE ID = 0";
}
$RecCashLog = mysql_query($query_RecCashLog, $MYCONN) or die(mysql_error());
$row_RecCashLog = mysql_fetch_assoc($RecCashLog);
$totalRows_RecCashLog = mysql_num_rows($RecCashLog);


/* mysql_select_db($database_MYCONN, $MYCONN);
$query_RecUser = "SELECT tb_users.ID, tb_users.UserName FROM tb_users ORDER BY tb_users.UserName";
$RecUser = mysql_query($query_RecUser, $MYCONN) or die(mysql_error());
$row_RecUser = mysql_fetch_assoc($RecUser);
$totalRows_RecUser = mysql_num_rows($RecUser); */

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecRegister = "SELECT tb_register.ID, tb_register.RegisterID FROM tb_register ORDER BY tb_register.RegisterID";
$RecRegister = mysql_query($query_RecRegister, $MYCONN) or die(mysql_error());
$row_RecRegister = mysql_fetch_assoc($RecRegister);
$totalRows_RecRegister = mysql_num_rows($RecRegister);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecLocation = "SELECT tb_locations.ID, tb_locations.LocationName FROM tb_locations ORDER BY tb_locations.LocationName";
$RecLocation = mysql_query($query_RecLocation, $MYCONN) or die(mysql_error());
$row_RecLocation = mysql_fetch_assoc($RecLocation);
$totalRows_RecLocation = mysql_num_rows($RecLocation);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecDepositList = "SELECT tb_deposit_list.ID, tb_deposit_list.Description FROM tb_deposit_list ORDER BY tb_deposit_list.Sort ASC";
$RecDepositList = mysql_query($query_RecDepositList, $MYCONN) or die(mysql_error());
$row_RecDepositList = mysql_fetch_assoc($RecDepositList);
$totalRows_RecDepositList = mysql_num_rows($RecDepositList);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecMetroList = "SELECT tb_metro_list.ID, tb_metro_list.Description FROM tb_metro_list ORDER BY tb_metro_list.Sort ASC";
$RecMetroList = mysql_query($query_RecMetroList, $MYCONN) or die(mysql_error());
$row_RecMetroList = mysql_fetch_assoc($RecMetroList);
$totalRows_RecMetroList = mysql_num_rows($RecMetroList);

mysql_select_db($database_MYCONN, $MYCONN);
$query_Recordset1 = "SELECT t.ID,CONCAT(Date(LogDate),'::',upper(u.UserName),'::',r.RegisterID) as Link  	
						FROM tb_cashlog t, tb_users u, tb_register r WHERE t.UserID = u.ID AND t.RegisterID = r.ID AND t.logdate >= (CAse when (select Date(ControlDate) from tb_controlview where status ='Y') is null then 
			Date('2000-01-01 00:00:00')
		else
			(select Date(ControlDate) from tb_controlview where status ='Y')
		end)" 	;

if(CurrentUserName()=="jacob" || CurrentUserName()=="admin" || CurrentUserName()=="master")
{
	$query_Recordset1 = $query_Recordset1." ORDER BY t.LogDate DESC ";
}
else
{
	$query_Recordset1 = $query_Recordset1." AND u.UserName = '".CurrentUserName()."' ORDER BY t.LogDate DESC ";
}
//echo $query_Recordset1;

$Recordset1 = mysql_query($query_Recordset1, $MYCONN) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecCreditCard = "SELECT tb_creditcard.ID, tb_creditcard.CardType, tb_creditcard.Amount FROM tb_creditcard  WHERE ParentID=".$parentid;
$RecCreditCard = mysql_query($query_RecCreditCard, $MYCONN) or die(mysql_error());
$row_RecCreditCard = mysql_fetch_assoc($RecCreditCard);
$totalRows_RecCreditCard = mysql_num_rows($RecCreditCard);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecDeposits = "SELECT tb_deposits.ID, tb_deposits.Description, tb_deposits.Amount FROM tb_deposits  WHERE ParentID=".$parentid;
$RecDeposits = mysql_query($query_RecDeposits, $MYCONN) or die(mysql_error());
$row_RecDeposits = mysql_fetch_assoc($RecDeposits);
$totalRows_RecDeposits = mysql_num_rows($RecDeposits);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecLunch = "SELECT tb_lunchamt.ID, tb_lunchamt.Description, tb_lunchamt.Amount FROM tb_lunchamt WHERE ParentID=".$parentid;
$RecLunch = mysql_query($query_RecLunch, $MYCONN) or die(mysql_error());
$row_RecLunch = mysql_fetch_assoc($RecLunch);
$totalRows_RecLunch = mysql_num_rows($RecLunch);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecMetro = "SELECT tb_metrocard.ID, tb_metrocard.Description, tb_metrocard.Amount FROM tb_metrocard  WHERE ParentID=".$parentid;
$RecMetro = mysql_query($query_RecMetro, $MYCONN) or die(mysql_error());
$row_RecMetro = mysql_fetch_assoc($RecMetro);
$totalRows_RecMetro = mysql_num_rows($RecMetro);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecOverRings = "SELECT tb_overrings.ID, tb_overrings.Description, tb_overrings.Amount FROM tb_overrings WHERE ParentID=".$parentid;
$RecOverRings = mysql_query($query_RecOverRings, $MYCONN) or die(mysql_error());
$row_RecOverRings = mysql_fetch_assoc($RecOverRings);
$totalRows_RecOverRings = mysql_num_rows($RecOverRings);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecPayouts = "SELECT tb_payouts.ID, tb_payouts.Description, tb_payouts.Amount FROM tb_payouts WHERE ParentID=".$parentid;
$RecPayouts = mysql_query($query_RecPayouts, $MYCONN) or die(mysql_error());
$row_RecPayouts = mysql_fetch_assoc($RecPayouts);
$totalRows_RecPayouts = mysql_num_rows($RecPayouts);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecCash = "SELECT tb_cash.ID, tb_cash.Cash_Hundred, tb_cash.Cash_Fifty, tb_cash.Cash_twenty, tb_cash.Cash_Ten, tb_cash.Cash_five, tb_cash.Cash_single, tb_cash.Roll_Quarter, tb_cash.Roll_Dime, tb_cash.Roll_Nickle, tb_cash.Roll_Penny, tb_cash.Coin_Quarter, tb_cash.Coin_Dime, tb_cash.Coin_Nickle, tb_cash.Coin_Penny, tb_cash.Coin_Dollar, tb_cash.Coin_Halfdollar FROM tb_cash WHERE ParentID=".$parentid;
$RecCash = mysql_query($query_RecCash, $MYCONN) or die(mysql_error());
$row_RecCash = mysql_fetch_assoc($RecCash);
$totalRows_RecCash = mysql_num_rows($RecCash);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecChecks = "SELECT tb_checks.ID, tb_checks.BankName, tb_checks.Amount FROM tb_checks WHERE ParentID=".$parentid;
$RecChecks = mysql_query($query_RecChecks, $MYCONN) or die(mysql_error());
$row_RecChecks = mysql_fetch_assoc($RecChecks);
$totalRows_RecChecks = mysql_num_rows($RecChecks);



function GetMultiplier($Description){ 
$return = 0;
if(strstr($Description, "$100")){
return $return = 100;
}
if(strstr($Description, "$10")){
return $return = 10;
}
if(strstr($Description, "$50")){
return $return = 50;
}
if(strstr($Description, "$20")){
return $return = 20;
}
if(strstr($Description, "$5")){
return $return = 5;
}
if(strstr($Description, "$1")){
return $return = 1;
}
if(strstr($Description, "$24")){
return $return = 24;
}
if(strstr($Description, "$7")){
return $return = 7;
}

if(strstr($Description, "$4")){
return $return = 4;
}

return $return;
}


function getUserID($usr,$database_MYCONN, $MYCONN){
	mysql_select_db($database_MYCONN, $MYCONN);
	$query_RecUser = "SELECT tb_users.ID FROM tb_users WHERE tb_users.UserName = '".$usr."'";
	$RecUser = mysql_query($query_RecUser, $MYCONN) or die(mysql_error());
	$row_RecUser = mysql_fetch_assoc($RecUser);
	$totalRows_RecUser = mysql_num_rows($RecUser);

	do 
	{  
	$usrid = $row_RecUser['ID'] ;
	
	} while ($row_RecUser = mysql_fetch_assoc($RecUser));
	$rows = mysql_num_rows($RecUser);
	if($rows > 0) {
	mysql_data_seek($RecUser, 0);
	$row_RecUser = mysql_fetch_assoc($RecUser);
	}

return $usrid;

}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
<?php include("../title.php") ;?>
</title>
<style type="text/css">
<!--
fieldset { border:1px solid green }

legend {
/*  padding: 0.5em 0.8em;*/
  border:1px solid #999999;
  background-color:#CCCCCC;
  color:#666666;
  font-size:90%;
  text-align:right;
  }
  
.style2 {
	color: #0000FF;
	font-weight: bold;
	font-size: 12px;
}
-->
</style>
<link rel="stylesheet" type="text/css" media="all" href="../calendar/calendar-win2k-1.css" title="win2k-1" />
<script type="text/javascript" src="../calendar/calendar.js"></script>
<script type="text/javascript" src="../calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="../calendar/calendar-setup.js"></script>
<script language="javascript1.2">
<!--
var requester = null;

function createXMLReq()
{
	 if (requester != null && requester.readyState != 0 && requester.readyState != 4)
	 {
	   requester.abort();
	 }
	
	 try
	 {
	   requester = new XMLHttpRequest();
	 }
	 catch (error)
	 {
	   try
	   {
		 requester = new ActiveXObject("Microsoft.XMLHTTP");
	   }
	   catch (error)
	   {
		 requester = null;
	
		 return false;
	   }
	  }
}
function updateDB(TblName, ID, CName, Value)
{
 /* Check for running connections */

  	createXMLReq();
  
	requester.onreadystatechange = onreadystatechangeReceipt;
	actionURL = "action.php?TblName=" + TblName+"&CName="+CName+"&ID="+ID+"&Value="+Value+"&Action=100";
	//	alert(actionURL);
	requester.open("POST", actionURL);
	requester.send(null);
	
	return true;

}

function deleteAll(TblName, ID, Scope)
{

var userresponse =	confirm("Do you want delete all cash log entries?");

if(userresponse == true ){
	window.location.href = "delete.php?ParentID="+ID+"&TblName=" + TblName+"&ID="+ID+"&Action="+Scope;	
	return true;
}

}

function deleteDB(ParentID, TblName, ID)
{
	window.location.href = "delete.php?ParentID="+ParentID+"&TblName=" + TblName+"&ID="+ID+"&Action=-1";
	return true;
}


function onreadystatechangeReceipt()
{
 /* If XMLHR object has finished retrieving the data */
 if (requester.readyState == 4)
 {
   /* If the data was retrieved successfully */
   if (requester.status == 200)
   {
     //alert("success");
	 WriteDetails();
   }
   /* IE returns a status code of 0 on some occasions, so ignore this case */
   else if (requester.status != 0)
   {
     alert("There was an error while retrieving the URL: " + requester.statusText);
   }
 }

 return true;
}

function WriteDetails()
{
//alert(requester.responseText);
if(requester.responseText != "1" )
{
alert("Error occured while database request.\nPlease review again.\n"+requester.responseText);
}

return true;
}

function CheckValue(obj)
{
	if(obj.value == ""){
		obj.value = 0;
	}

}
function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}
function GetCookie (name) { 
var arg = name + "="; 
var alen = arg.length; 
var clen = document.cookie.length; 
var i = 0; 
while (i < clen) { 
var j = i + alen; 
if (document.cookie.substring(i, j) == arg) 
return getCookieVal (j); 
i = document.cookie.indexOf(" ", i) + 1; 
if (i == 0) break; 
} 
return null; 
}
function openWindow(url)
{
    var w = window.open (url, "win", "height=400,width=800,location=no,menubar=no,resizable,scrollbars=no,status=no,toolbar=no");
}

//-->
</script>
<link rel="stylesheet" type="text/css" href="../mystyle.css">
<style type="text/css">
<!--
.style3 {color: #000000}
.style5 {color: #000000; font-weight: bold; }
.style9 {color:#000033; font-weight: bold; font-size: 18px; }
.style10 {
	font-size: medium;
	font-weight: bold;
}
-->
</style>
</head>
<!--1126892761-->
<body onLoad="validateDate();">
<script language="javascript1.2">
function EditLog(val){
window.location.href="aaa3.php?ID="+val;
}
function makeAllReadOnlyExceptSubmit()
{
var arrElements = document.all;
	for(var i=0; i<arrElements.length; i++){
	//arrElements[i].disabled=true;
	arrElements[i].readOnly=true;
	if(arrElements[i].type=="button" || arrElements[i].type=="submit"){
	arrElements[i].disabled=true;
	}
	}
}
function validateDate(){
var curdt = new Date();
var today=curdt.getFullYear()+"/"+curdt.getMonth()+"/"+curdt.getDate();
var lgdate=document.form1.frmlogdate.value;
var usrInput;
	if(today==lgdate){
	alert("same day, you can maked changes!!!");
	}else{
	alert(document.form1.adminPWD.value);
		if(document.form1.adminPWD.value!="test"){
					usrInput=prompt("Enter admin password!!!");
					if(usrInput=="test"){
						document.form1.adminPWD.value=usrInput;
					}else{
						makeAllReadOnlyExceptSubmit();
						alert("pwd is wrong, try again");
					}
			}
	}

}
</script>
<?php 
if(CurrentUserName()=="jacob" or CurrentUserName()=="admin" or CurrentUserName()=="master")
{
	include ("../header.php") ;
}

?>

<table border="0" cellpadding="0" cellspacing="0" class="TAB-MAIN">
  <tr >
    <td colspan="2"><span class="style9"> <strong>Edit Cash Log :</strong></span><span class="style9">
	<select  style="width:300;" name="EditLog" id="EditLog" onChange="EditLog(this.options[this.selectedIndex].value);">
  <option value="0">Select Log for Edit</option>
  <?php do { ?>
  <option value="<?php echo $row_Recordset1['ID']; ?>"><?php echo $row_Recordset1['Link']; ?></option>
  <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</select>
</span> </td>
    <td align="right" colspan="2"><div class="style9"  align="right">
        <script>
		var curdt = new Date();
		document.write("Today : "+(curdt.getMonth()+1)+"/"+curdt.getDate()+"/"+curdt.getFullYear()+"::"+curdt.getHours()+":"+curdt.getMinutes()+":"+curdt.getSeconds()+"");
		</script>
      </div></td>
  </tr>
  <tr>
    <td colspan="5" bgcolor="#000000" height="3px"></td>
  </tr>
  <tr bordercolor="#999999">
    <td colspan="4" valign="top" nowrap="nowrap" bgcolor="#CCCCCC" class="COLUMN-HEADER-MAIN"><?php 
	echo "Welcome : ".CurrentUserName(); 
 	if(CurrentUserName()=="jacob" OR CurrentUserName()=="admin" || CurrentUserName()=="master")
	{
		echo	" | <a href='tb_metro_listlist.php'>Go To List</a>";
	}
	else
	{
		echo "";
	};
	?>
      | <a href="../logout.php">Logout</a>
      <?PHP if($row_RecCashLog['ID']!=0){ ?>
      | <a href='#' onClick="openWindow('history.php?ID=<?php echo $row_RecCashLog['ID'] ?>');" >Print View </a>
      <?php }?>
    </td>
    <td bgcolor="#CCCCCC"  nowrap="nowrap" valign="top" align="right"><?php if($parentid > 0){?>
      <input type="button"  style="background:#FF0000; color:#FFFFFF; font-weight:bold; height:22px; width:160px" value="Add New Cashlog Entry" name="AddNewLog" onClick="window.location.href='aaa3.php?ID=0'">
      <?php }else{?>
      &nbsp;
      <?php }?>
    </td>
  </tr>
  <tr>
    <td colspan="5"><div>
        <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
          <table style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px">
            <tr>
              <td valign="top"><strong>LogDate:</strong></td>
              <td  valign="top" nowrap><span><span>
                <input type="text"  style="width:100px" name="frmlogdate" value="<?php echo FormatDateTime($row_RecCashLog['LogDate'],5); ?>" onChange="updateDB('tb_cashlog',<?php echo ($row_RecCashLog['ID']=="")?0:$row_RecCashLog['ID']; ?>, 'LogDate', this.value);" />
                </span><img src="../images/ew_calendar.gif" id="cfrmlogdate" alt="Pick a Date" style="cursor:pointer;cursor:hand;">
                <script type="text/javascript">
Calendar.setup(
{
inputField : "frmlogdate", // ID of the input field
ifFormat : "%Y/%m/%d", // the date format
button : "cfrmlogdate" // ID of the button
}
);
    </script>
                </span></td>
              <td valign="top"><strong>RegID:</strong></td>
              <td valign="top" width="100px"><select  name="frmreigisterID"  onChange="updateDB('tb_cashlog',<?php echo ($row_RecCashLog['ID']=="")?0:$row_RecCashLog['ID']; ?>, 'RegisterID', this.value);" >
                  <?php
					do {  
					?>
                  <option value="<?php echo $row_RecRegister['ID']?>"
					
					<?php if (!(strcmp($row_RecRegister['ID'], $row_RecCashLog['RegisterID'])))
					{
					echo "selected=\"selected\"";
					} ?>><?php echo $row_RecRegister['RegisterID'] ?></option>
                  <?php
					} while ($row_RecRegister = mysql_fetch_assoc($RecRegister));
					$rows = mysql_num_rows($RecRegister);
					if($rows > 0) {
					mysql_data_seek($RecRegister, 0);
					$row_RecRegister = mysql_fetch_assoc($RecRegister);
					}
					?>
                </select>
                <input type="hidden" name="frmUserID" value="<?PHP echo getUserID();?>">
                <input type="hidden" name="frmLocationID" value="ZZ">
              </td>
              <td valign="top" nowrap="nowrap"><strong>Total IPP:</strong></td>
              <td valign="top" nowrap="nowrap" width="60px"><input type="text" name="frmippsales" value="<?php echo ($row_RecCashLog['TotalIPPSales']=="")?0:$row_RecCashLog['TotalIPPSales']; ?>" onChange="updateDB('tb_cashlog',<?php echo ($row_RecCashLog['ID']=="")?0:$row_RecCashLog['ID']; ?>, 'TotalIPPSales', this.value);"/></td>
              <td  valign="top" nowrap="nowrap"><strong>X Read:</strong></td>
              <td valign="top" nowrap="nowrap" width="60px"><input type="text" name="frmxreading" value="<?php echo ($row_RecCashLog['XReading']=="")?0:$row_RecCashLog['XReading']; ?>" onChange="updateDB('tb_cashlog',<?php echo ($row_RecCashLog['ID']=="")?0:$row_RecCashLog['ID']; ?>, 'XReading', this.value);"/></td>
              <td valign="top"><input type="submit" name="frmSubmit" value="Add Master Cash Log Entries" <?php echo ($parentid > 0)?" disabled":" "; ?> /></td>
              <!--<td  valign="top"><input type="button" name="frmUpdate" value="Update" /></td>			-->
              <td valign="top" nowrap="nowrap" ><input type="button" name="frmDelete" value="Delete All" onClick="deleteAll('tb_cashlog', <?php echo $parentid ?>,99);"/>
              </td>
            </tr>
          </table>
          <?php 
$IPPSaleAmt = $row_RecCashLog['TotalIPPSales'] ;
$XReadingAmt = $row_RecCashLog['XReading'] ;
?>
          <input type="hidden" name="MM_insert" value="form1">
        </form>
      </div></td>
  </tr>
  <!-- BOXES BEGINS-->
  <?php if($parentid > 0){ ?>
  <tr>
    <td rowspan="2" valign="top"><?php include("../checkInfo.php") ?>
      <?php include("../depositInfo.php") ?></td>
    <td rowspan="2" valign="top"><?php include("../creditInfo.php") ?>
      <?php include("../lunchInfo.php") ?></td>
    <td rowspan="2" valign="top"><?php include("../overringInfo.php") ?>
      <?php include("../payoutInfo.php") ?></td>
    <td  rowspan="2" valign="top" bordercolor="#999999"><?php include("../coinInfo.php") ?></td>
    <td  valign="top"><?php include("../metroInfo.php")?></td>
  </tr>
  <tr>
    <td colspan="5"></td>
  </tr>
  <tr>
    <td colspan="5" bgcolor="#000066" height="3px"></td>
  </tr>
  <tr>
    <td colspan="5" nowrap="nowrap" valign="top"><div class="style9" id="grandtotal" align="right" >GRAND TOTALS :
        <?php
			echo $CheckAmt+$CashAmt+$CreditAmt+$DepositAmt+$LunchAmt+$MetroAmt+$OverringAmt+$PayoutAmt+$IPPSaleAmt+$XReadingAmt;
			?>
      </div></td>
  </tr>
 <!-- <tr>
    <td colspan="5"><?php //("ActivitySummary.php");?></td>
  </tr>
  -->
  <?php }else{ ?>
  <tr bgcolor="#CCCCCC">
    <td colspan="5"  height="200" align="center"><span class="style10">Please enter Cash Long Master entries first and then enter details.</span></td>
  </tr>
  <?php }?>
</table>
</body>
</html>
<?php
mysql_free_result($RecCashLog);

//mysql_free_result($RecUser);

mysql_free_result($RecRegister);

mysql_free_result($RecLocation);

mysql_free_result($RecDepositList);

mysql_free_result($RecMetroList);

mysql_free_result($Recordset1);

mysql_free_result($RecCreditCard);

mysql_free_result($RecDeposits);

mysql_free_result($RecLunch);

mysql_free_result($RecMetro);

mysql_free_result($RecOverRings);

mysql_free_result($RecPayouts);

mysql_free_result($RecCash);

mysql_free_result($RecChecks);
?>
<?php 
if($HTTP_SESSION_VARS["jacob_status_User"]=="jacob" || CurrentUserName()=="admin" || CurrentUserName()=="master")
{
	include ("../footer.php") ;
}

?>
<?php  
/* echo '<pre>';
echo $SessFrmLogDate;
echo "<br>";
echo $SessFrmRegisterID;
echo "<br>";
echo $SessFrmUserID;
echo "<br>";
echo $SessFrmLocationID;
echo "<br> ParentID=";
echo $SessFrmParentID;

echo '</pre>'; */ ?>
